package luafrontend.values;

import luafrontend.exceptions.ConversionException;

public class LuaNumber extends LuaValue {
	private final Double nbr;
	
	public LuaNumber(double nbr) {
		this.nbr = nbr;
	}
	
	public LuaNumber asNumber() throws ConversionException {
		return this;
	}
	
	public LuaString asString() throws ConversionException {
		return new LuaString("" + nbr);
	}
	
	public double getNumber() {
		return nbr;
	}
	
	public String toString() {
		return "" + nbr;
	}

	@Override
	public int hashCode() {
		return nbr.hashCode();
	}
	
	@Override
	public boolean equals(Object other) {
		return other instanceof LuaNumber && nbr.equals(((LuaNumber) other).nbr);
	}
}
